package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.dtos.WmSensitiveDto;
import com.heima.wemedia.service.WmchannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/v1/channel")
public class WmchannelController {

    @Autowired
    private WmchannelService wmchannelService;

    @GetMapping("/channels")
    public ResponseResult getChannels(){
        return wmchannelService.getChannels();
    }

    /**
     * 获取频道列表
     * @return
     */
    @PostMapping("/list")
    public ResponseResult getList(@RequestBody Map<String,String> map){
        return wmchannelService.getchannelList(map);
    }

    /**
     * 添加频道数据
     */
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody Map<String,Object> map){
        return wmchannelService.saveChannel(map);
    }

    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody ChannelDto dto){
        return wmchannelService.updateChannel(dto);
    }

    @GetMapping("/del/{id}")
    public ResponseResult delChannel(@PathVariable int id){
        return wmchannelService.delChannel(id);
    }

}
